package cn.richard.home.api.repository

import cn.richard.base.api.BaseRepository
import cn.richard.base.api.NetConstants
import cn.richard.base.bean.ResultData
import cn.richard.home.api.data.PicCategoryList
import cn.richard.home.api.data.PicList
import cn.richard.home.api.service.PictureService
import okhttp3.OkHttpClient

/**
 ***************************************
 * 项目名称:base
 * @Author wuzhiguo
 * 邮箱：wuzhiguo@ksjgs.com
 * 创建时间: 2019/12/31     10:53 AM
 * 用途：相当于 kaishu app 的 ksApiManager ，只是 抽离了。
 ***************************************
 *
 */
class PictureRepository() : BaseRepository() {


    override fun baseUrl(): String {
        return NetConstants.BaseUrl.PIC_URL
    }

    override fun handleBuilder(builder: OkHttpClient.Builder) {
        //TODO 重写增加build参数
        super.handleBuilder(builder)
    }

    suspend fun getPictureCategories(adult: Boolean, first: Int): ResultData<PicCategoryList> {
        return safeApiCall(call = {
            getService(PictureService::class.java).getPicCategory(adult, first)
        })
    }

    suspend fun getPictureList(categoryId: String, limit: Int, skip: Int, order: String): ResultData<PicList> {
        return safeApiCall(call = {getService(PictureService::class.java).getPicList(categoryId, limit, skip, adult = false, first = 0, order)})
    }





}